package cn.ffcs.util.ext;

public class Expression
{
    /**结果值**/
    private String sqlString;
    
    /**
     * 获取sql
     * @return
     */
    private String toSqlString(){
        return this.getSqlString();
    }
    
    /**
     * like操作
     * @param field
     * @param value
     */
    public void like(String field,Object value){
        String str=field+" like '%"+value.toString()+"%'";
        this.setSqlString(str);
    }
    
    /**
     * 等于操作
     * @param field
     * @param value
     */
    public void eq(String field,Object value){
        String str="";
        if (value instanceof Integer){
            str=field+"="+value.toString()+"";
        }else if (value instanceof String){
            str=field+"='"+value+"'";
        }
        this.setSqlString(str);
    } 
    
    /**
     * and操作
     * @param e1
     * @param e2
     */
    public void and(Expression e1,Expression e2){
        this.setSqlString(e1.getSqlString()+" and "+e2.getSqlString());
    }
    
    /**
     * or操作
     * @param e1
     * @param e2
     */
    public void or(Expression e1,Expression e2){
        this.setSqlString(e1.getSqlString()+" or "+e2.getSqlString());
    }
    
    public void gt(String field,Object value){
        
    }
    
    public void lt(String field,Object value){
        
    }

    /**
     * @return the sqlString
     */
    public String getSqlString()
    {
        return sqlString;
    }

    /**
     * @param sqlString the sqlString to set
     */
    public void setSqlString(String sqlString)
    {
        this.sqlString = sqlString;
    }
}
